package com.lancoo.ccas53.arrangecourse.entities;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * @Description 教室课时分组类
 * @Author Fortysun
 * @Date 2023-02-06 19:12
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class TimeslotRoom implements Comparable<TimeslotRoom>, Serializable {

    public TimeslotRoom(TimeslotRoom cloneable) {
        this.timeslotRoomId = cloneable.getTimeslotRoomId();
        this.timeslotCode = cloneable.getTimeslotCode();
        this.timeslotName = cloneable.getTimeslotName();
        this.periodType = cloneable.getPeriodType();
        this.period = cloneable.getPeriod();
        this.dayNo = cloneable.getDayNo();
        this.roomId = cloneable.getRoomId();
        this.roomName = cloneable.getRoomName();
        this.roomType = cloneable.getRoomType();
        this.buildingId = cloneable.getBuildingId();
        this.buildingName = cloneable.getBuildingName();
        this.weeks = cloneable.getWeeks();
        this.campusId = cloneable.getCampusId();
        this.capacity = cloneable.getCapacity();
        this.isRemove = cloneable.getIsRemove();
        this.accommodateClassNum = cloneable.getAccommodateClassNum();
    }

    //课时教室id
    private int timeslotRoomId;

    //时段编码，0108代表每周第1天，第8节课
    private String timeslotCode;

    //时段名称
    private String timeslotName;

    /**
     * 1.上午； 2.下午
     */
    private Integer periodType;

    /**
     * 节次
     */
    private Integer period;


    //日期编号，周一01，周二02， 周三03...以此类推
    private String dayNo;
    //教室id
    private Long roomId;

    //教室名称
    private String roomName;

    //教室类型，以物联网的定义为准；
    private Integer roomType;
    private String roomTypeName;

    //教室容量
    private Integer capacity;

    //楼宇id
    private Integer buildingId;

    /**
     * 楼宇名
     */
    private String buildingName;

    //排课周次，用二进制字符表示，1代表可排课，0代表不可排，第几位代表第几周
    //比如一个学期有18周，100100000000000000代表第一周和第三周可排课
    //初始化的时候，默认所有位置都是1的，即所有周都可排
    private String weeks;
    private String clashWeeks;
    private int weekSize;

    //校区id；
    private String campusId;

    //标记这个分组信息，释放需要从列表remove，用于排课的处理；
    private Boolean isRemove = false;

    //可容纳班级数
    private Integer accommodateClassNum;

    @Override
    public int compareTo(TimeslotRoom o) {
        //按照教室容量，从小到大排序
        if (o.getCapacity() < this.getCapacity()) {
            return 1;
        } else if (o.getCapacity() > this.getCapacity()) {
            return -1;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        if (getClass() != obj.getClass()) {
            return false;
        }

        boolean bRet = false;
        TimeslotRoom timeslotRoom = (TimeslotRoom) obj;
        if (this.roomId.equals(timeslotRoom.getRoomId())
                && this.timeslotCode.equals(timeslotRoom.getTimeslotCode())) {
            bRet = true;
        }

        return bRet;
    }
}
